﻿using DEL.Sys;
using IBLL.Sys;
using System.Collections.Generic;
using System.Linq;

namespace BLL.Sys
{
    public class RoleMenuService : BaseService<RoleMenu>, IRoleMenuService
    { 
        public override void SetCurrentRepository()
        {           
            CurrentRepository = DALFactory.SetRoleMenuRepository();
        }

        /// <summary>
        /// 根据角色Id获取菜单及功能
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public List<int> GetMenuIdsByRoleId(int roleId)
        {
            var roleMenus = GetEntitysByLambdaAndSort(it => it.RoleId == roleId, o => o.SortIndex, true).ToList();
            var menuIds = from t in roleMenus select t.MenuId;
            return menuIds.ToList();
        }
    }
}
